package com.ruoyi.web.controller.cat;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.cat.domain.AdTicketIprecord;
import com.ruoyi.cat.service.IAdTicketIprecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ip地址记录 折扣Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/system/ticketIprecord")
public class AdTicketIprecordController extends BaseController
{
    @Autowired
    private IAdTicketIprecordService adTicketIprecordService;

    /**
     * 查询ip地址记录 折扣列表
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdTicketIprecord adTicketIprecord)
    {
        startPage();
        List<AdTicketIprecord> list = adTicketIprecordService.selectAdTicketIprecordList(adTicketIprecord);
        return getDataTable(list);
    }

    /**
     * 导出ip地址记录 折扣列表
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:export')")
    @Log(title = "ip地址记录 折扣", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdTicketIprecord adTicketIprecord)
    {
        List<AdTicketIprecord> list = adTicketIprecordService.selectAdTicketIprecordList(adTicketIprecord);
        ExcelUtil<AdTicketIprecord> util = new ExcelUtil<AdTicketIprecord>(AdTicketIprecord.class);
        util.exportExcel(response, list, "ip地址记录 折扣数据");
    }

    /**
     * 获取ip地址记录 折扣详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(adTicketIprecordService.selectAdTicketIprecordById(id));
    }

    /**
     * 新增ip地址记录 折扣
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:add')")
    @Log(title = "ip地址记录 折扣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdTicketIprecord adTicketIprecord)
    {
        return toAjax(adTicketIprecordService.insertAdTicketIprecord(adTicketIprecord));
    }

    /**
     * 修改ip地址记录 折扣
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:edit')")
    @Log(title = "ip地址记录 折扣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdTicketIprecord adTicketIprecord)
    {
        return toAjax(adTicketIprecordService.updateAdTicketIprecord(adTicketIprecord));
    }

    /**
     * 删除ip地址记录 折扣
     */
    @PreAuthorize("@ss.hasPermi('system:iprecord:remove')")
    @Log(title = "ip地址记录 折扣", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adTicketIprecordService.deleteAdTicketIprecordByIds(ids));
    }
}
